﻿using System.Text.RegularExpressions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using YSUtils.Assembly;

namespace UnitTest
{
    /// <summary>
    ///This is a test class for AssemblyInfoUtilTest and is intended
    ///to contain all AssemblyInfoUtilTest Unit Tests
    ///</summary>
	[TestClass]
	public class AssemblyInfoUtilTest
	{
		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext
		{
			get; set;
		}

		#region Additional test attributes
		// 
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		//[ClassInitialize()]
		//public static void MyClassInitialize(TestContext testContext)
		//{
		//}
		//
		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//public static void MyClassCleanup()
		//{
		//}
		//
		//Use TestInitialize to run code before running each test
		//[TestInitialize()]
		//public void MyTestInitialize()
		//{
		//}
		//
		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//public void MyTestCleanup()
		//{
		//}
		//
		#endregion


		/// <summary>
		///A test for AssemblyVersion
		///</summary>
		[TestMethod]
		public void AssemblyVersionTest()
		{
			var actual = AssemblyInfoUtil.AssemblyVersion;

			var regex = new Regex(@"([0-9]+\.){3}[0-9]+");

			Assert.IsTrue(regex.Match(actual).Success, "AssemblyVersion failed.");
		}

		/// <summary>
		///A test for AssemblyTitle
		///</summary>
		[TestMethod]
		public void AssemblyTitleTest()
		{
			const string expected = "YSUtils";
			var actual = AssemblyInfoUtil.AssemblyTitle;
			Assert.AreEqual(expected, actual, "AssemblyTitle failed.");
		}

		/// <summary>
		///A test for AssemblyProduct
		///</summary>
		[TestMethod]
		public void AssemblyProductTest()
		{
			const string expected = "YSUtils";
			var actual = AssemblyInfoUtil.AssemblyProduct;
			Assert.AreEqual(expected, actual, "AssemblyProduct failed.");
		}

		/// <summary>
		///A test for AssemblyDescription
		///</summary>
		[TestMethod]
		public void AssemblyDescriptionTest()
		{
			const string expected = "General library";
			var actual = AssemblyInfoUtil.AssemblyDescription;
			Assert.AreEqual(expected, actual, "AssemblyDescription failed.");
		}

		/// <summary>
		///A test for AssemblyCopyright
		///</summary>
		[TestMethod]
		public void AssemblyCopyrightTest()
		{
			var actual = AssemblyInfoUtil.AssemblyCopyright;

			var regex = new Regex(@"Copyright(.)+StulSoft");

			Assert.IsTrue(regex.Match(actual).Success, "AssemblyCopyright failed.");
		}

		/// <summary>
		///A test for AssemblyCompany
		///</summary>
		[TestMethod]
		public void AssemblyCompanyTest()
		{
			const string expected = "StulSoft";
			var actual = AssemblyInfoUtil.AssemblyCompany;
			Assert.AreEqual(expected, actual, "AssemblyCompany failed.");
		}
	}
}
